package com.cmc.cloud.cmclink.doc.api.document;

import com.cmc.cloud.cmclink.doc.api.document.rep.BlnoCheckSiRespDto;
import com.cmc.cloud.cmclink.doc.api.document.req.si.*;
import com.cmc.cloud.cmclink.doc.constant.DocApiConstants;
import com.cmes.framework.common.pojo.CommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
import java.util.List;

/**
 * 订舱拆分合并
 *
 * @author codegen
 */
@FeignClient(name = DocApiConstants.NAME)
@Tag(name = "RPC - 服务 提单拆分合并")
public interface SiSplitCombineApi {

    String PREFIX = DocApiConstants.PREFIX + "/si";


    /**
     * 校验是否可以拆单
     *
     * @param originalBlnoId id
     * @return BlnoSplitInfoDto
     */
    @GetMapping(PREFIX + "/check_si_split/{originalBlnoId}")
    @Operation(summary = "校验是否可以拆单")
    CommonResult<Void> checkOriginalSpiltData(@PathVariable("originalBlnoId") Long originalBlnoId);

    /**
     * 拆分子单校验SI数据
     *
     * @param blnoCheckSiReqDto dto
     * @return BlnoSplitInfoDto
     */
    @Operation(summary = "check SI")
    @PostMapping(PREFIX+"/checkSi")
    CommonResult<BlnoCheckSiRespDto> checkSi(@Valid @RequestBody BlnoCheckSiReqDto blnoCheckSiReqDto);

    /**
     * 提单拆分
     *
     * @param blnoSpiltReqDto dto
     * @return Long 返回拆单操作Id(拆单)
     */
    @PostMapping(PREFIX + "/spilt")
    @Operation(summary = "提单拆单并提交申请")
    CommonResult<Long> blnoSpiltAndApply(@RequestBody BlnoSpiltReqDto blnoSpiltReqDto);

    /**
     * 提单合并
     *
     * @param blnoCombineDto dto
     * @return id
     */
    @PostMapping(PREFIX + "/combine")
    @Operation(summary = "提单并单并提交申请")
    CommonResult<Long> blnoCombineAndApply(@RequestBody BlnoCombineDto blnoCombineDto);

    /**
     * 拆单详情
     *
     * @param originalBlnoId id
     * @return BlnoSplitInfoDto
     */
    @GetMapping(PREFIX + "/split-blno/{originalBlnoId}")
    @Operation(summary = "拆单详情")
    CommonResult<BlnoSplitInfoDto> getSplitBlnoDetail(@PathVariable("originalBlnoId") Long originalBlnoId);

    /**
     * 提单可并单列表查询
     *
     * @param originalBlnoId
     * @return
     * @throws Exception
     */
    @GetMapping(PREFIX + "/combine-blno/list/{originalBlnoId}")
    @Operation(summary = "根据原单查询可以合并的提单")
    CommonResult<List<BlnoCombineListDto>> listBlnoCombine(@PathVariable("originalBlnoId") Long originalBlnoId) throws Exception;

}
